//
//  OosAbstractEntryParser.m
//  oos4ios
//
//  Created by Pablo Gonzalez on 5/12/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import "OosAbstractEntryParser.h"
#import <oos4ios/Exceptions/MethodNotImplementedException.h>

@implementation OosAbstractEntryParser

- (id) parseEntry: (OosEntry *) entry {
    if ([entry isKindOfClass: [NSDictionary class]]) {
        return [self parseJsonEntry: (NSDictionary *)entry];
    } else {
        [MethodNotImplementedException raiseForSelector:_cmd 
                                            inObject:self];
        return nil;
    }
}

- (OosEntry *) reverseParseEntry: (OosObject *) object
{
    [MethodNotImplementedException raiseForSelector:_cmd 
                                           inObject:self];
    return nil;
}
- (void) reverseParseObject: (OosObject*)object 
                  intoEntry: (OosEntry*)entry
{
    [MethodNotImplementedException raiseForSelector:_cmd 
                                           inObject:self];
}

- (void) parseEntry: (OosEntry *) entry 
       withCallback: (id<IOosParserCallback>) callback
{
    [self reportResult: [self parseEntry:entry] 
          withCallback: callback];
    
}

- (void) reverseParseEntry: (OosObject *) object 
              withCallback: (id<IOosParserCallback>) callback
{
    [self reportResult: [self reverseParseEntry:object] 
          withCallback: callback];
    
}
- (void) reverseParseObject: (OosObject*)object 
                  intoEntry: (OosEntry*)entry 
               withCallback: (id<IOosParserCallback>) callback
{
    [self reverseParseObject:object intoEntry:entry];
    [self reportResult: entry
          withCallback: callback];
}

#pragma mark - json addons

- (id)parseJsonEntry:(NSDictionary *)jsonEntry
{
    [MethodNotImplementedException raiseForSelector:_cmd 
                                           inObject:self];
    return nil;
}

- (void)parseJsonEntry:(NSDictionary *)jsonEntry withCallback:(id<IOosParserCallback>)callback
{
    [self reportResult: [self parseJsonEntry:jsonEntry] 
          withCallback: callback];
}

@end
